document.addEventListener('DOMContentLoaded', function() {
    if (location.href.indexOf(domain_mp) > -1) {
        var subStr = GetQueryString(location.href,'account');
        if(subStr){
            $('#jumpUrl').attr('href',host+'/#/scan?id='+subStr);
        }
        $('a.weui-desktop-btn.weui-desktop-btn_primary').attr('target','');//群发消息按钮去掉target
    }
    if (location.href.indexOf(url_sys) > -1) {
        $('body ').on('click', '.xuehai-aside-menu ul li', function(){
            var account = $(this).attr('account');
            var type = $(this).attr('type');
            var login = $(this).attr('login');
            //公号登陆和公号管理都存在事件login == 1限制事件执行只在公号登陆
            if(login == 1){
                chrome.runtime.sendMessage({action: "change_wx", id: account}, function(response) {
                    var clientHeight = document.documentElement.clientHeight;
                    $('.el-main #wechat_iframe').remove();
                    $('.el-main').append('<iframe ref="iframe" id="wechat_iframe" src="" width="100%" height="'+clientHeight+'"></iframe>');
                    var iframe_doc = document.getElementById('wechat_iframe');
                    var link = '';
                    if (response.success) {
                        link = url_get_wx_scan + '?id=' + account;
                    }else{
                        if(type == 3){
                            link = page_xcx_home + response.token + '&account=' + account;
                        }else{
                            link = page_mp_home + response.token + '&account=' + account;
                        }
                    }
                    iframe_doc.src = 'javascript:"<script>location.replace(\''+link+'\')<\/script>"';
                });
            }
        })
    }
});

